/**
 * 
 */

	var req;
	function checkAvailability(){
		var date=document.getElementById('datepicker').value;
		var from=date+' '+document.getElementById('fromTime').value;
		var to=date+' '+document.getElementById('toTime').value;	
		var num=document.getElementById('numberOfPeople').value;
		var url="CheckAvailability.jsp?from=" +from+"&to="+to+"&num="+num;

		if(window.XMLHttpRequest) {
			req = new XMLHttpRequest();
		} else if (window.ActiveXObject) {
			req = new ActiveXObject("Microsoft.XMLHTTP");
		}
		req.open("GET", url, true);
		req.onreadystatechange = callback;
		req.send(null);
	}
	function callback() {
		if(req.readyState == 4) {
			if(req.status == 200) {
				alert(req.responseText);
				var table=req.responseXML.getElementsByTagName("table")[0];
				//alert(msg);
		        setTable(table.childNodes[0].nodeValue);
			}
		}
	}
	
	function setTable(mTalbe){
		alert("Fuck");
		mtable=document.getElementById("mtable");
		if(-1==mtable){
			mtable.innerHTML = "<font color='red'>No Table Available</font>";
		}
		else{
			mtable.innerHTML = "<font color='red'>Table #"+mtable+" is Available</font>";
		}
	}
